import axios from 'axios'
import globalConfig from '../server/config'
import request from 'superagent'

export default {
  getWeChatOpenid (code, req) {
    const url = `${globalConfig.weChat.accessToken}appid=${globalConfig.weChat.appID}&secret=${globalConfig.weChat.appSecret}&code=${code}&grant_type=authorization_code`
    return axios.get(url)
  },

  getUserIdByOpenId (datas, req) {
    return request.post(globalConfig.userService.url + '/weChatFacade/getUserIdByOpenId').send(datas)
  },

  getUserIdBytoken (token, req) {
    return request.post(globalConfig.userService.url + '/loginFacade/getUserInfoByToken').send({token: token})
  }
}
